/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HuyNVK
 */
@Entity
@Table(name = "EMPLOYEE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
    @NamedQuery(name = "Employee.findByEmployeeID", query = "SELECT e FROM Employee e WHERE e.employeeID = :employeeID"),
    @NamedQuery(name = "Employee.findByName", query = "SELECT e FROM Employee e WHERE e.name = :name"),
    @NamedQuery(name = "Employee.findByShortName", query = "SELECT e FROM Employee e WHERE e.shortName = :shortName"),
    @NamedQuery(name = "Employee.findByGender", query = "SELECT e FROM Employee e WHERE e.gender = :gender"),
    @NamedQuery(name = "Employee.findByBirth", query = "SELECT e FROM Employee e WHERE e.birth = :birth"),
    @NamedQuery(name = "Employee.findByPersonalID", query = "SELECT e FROM Employee e WHERE e.personalID = :personalID"),
    @NamedQuery(name = "Employee.findByPassword", query = "SELECT e FROM Employee e WHERE e.password = :password")})
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "EmployeeID")
    private Integer employeeID;
    @Basic(optional = false)
    @Column(name = "Name")
    private String name;
    @Basic(optional = false)
    @Column(name = "ShortName")
    private String shortName;
    @Basic(optional = false)
    @Column(name = "Gender")
    private boolean gender;
    @Basic(optional = false)
    @Column(name = "Birth")
    @Temporal(TemporalType.TIMESTAMP)
    private Date birth;
    @Column(name = "PersonalID")
    private String personalID;
    @Basic(optional = false)
    @Column(name = "Password")
    private String password;
    @JoinColumn(name = "PositionID", referencedColumnName = "PositionID")
    @ManyToOne(optional = false)
    private Position positionID;
    @OneToMany(mappedBy = "fixedBy")
    private Collection<Defectlog> defectlogCollection;
    @OneToMany(mappedBy = "assignedTo")
    private Collection<Defectlog> defectlogCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "defectedBy")
    private Collection<Defectlog> defectlogCollection2;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pm")
    private Collection<Project> projectCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "employee")
    private Collection<Employeeproject> employeeprojectCollection;

    public Employee() {
    }

    public Employee(Integer employeeID) {
        this.employeeID = employeeID;
    }

    public Employee(Integer employeeID, String name, String shortName, boolean gender, Date birth, String password) {
        this.employeeID = employeeID;
        this.name = name;
        this.shortName = shortName;
        this.gender = gender;
        this.birth = birth;
        this.password = password;
    }

    public Integer getEmployeeID() {
        return employeeID;
    }

    public void setEmployeeID(Integer employeeID) {
        this.employeeID = employeeID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public boolean getGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public String getPersonalID() {
        return personalID;
    }

    public void setPersonalID(String personalID) {
        this.personalID = personalID;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Position getPositionID() {
        return positionID;
    }

    public void setPositionID(Position positionID) {
        this.positionID = positionID;
    }

    @XmlTransient
    public Collection<Defectlog> getDefectlogCollection() {
        return defectlogCollection;
    }

    public void setDefectlogCollection(Collection<Defectlog> defectlogCollection) {
        this.defectlogCollection = defectlogCollection;
    }

    @XmlTransient
    public Collection<Defectlog> getDefectlogCollection1() {
        return defectlogCollection1;
    }

    public void setDefectlogCollection1(Collection<Defectlog> defectlogCollection1) {
        this.defectlogCollection1 = defectlogCollection1;
    }

    @XmlTransient
    public Collection<Defectlog> getDefectlogCollection2() {
        return defectlogCollection2;
    }

    public void setDefectlogCollection2(Collection<Defectlog> defectlogCollection2) {
        this.defectlogCollection2 = defectlogCollection2;
    }

    @XmlTransient
    public Collection<Project> getProjectCollection() {
        return projectCollection;
    }

    public void setProjectCollection(Collection<Project> projectCollection) {
        this.projectCollection = projectCollection;
    }

    @XmlTransient
    public Collection<Employeeproject> getEmployeeprojectCollection() {
        return employeeprojectCollection;
    }

    public void setEmployeeprojectCollection(Collection<Employeeproject> employeeprojectCollection) {
        this.employeeprojectCollection = employeeprojectCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (employeeID != null ? employeeID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employee)) {
            return false;
        }
        Employee other = (Employee) object;
        if ((this.employeeID == null && other.employeeID != null) || (this.employeeID != null && !this.employeeID.equals(other.employeeID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Employee[ employeeID=" + employeeID + " ]";
    }
    
}
